/**
 * @Author:Geln Yang
 * @Created:2008-9-15 $ Revision: 1.0 $ $ Author: Geln Yang $ $ Date: 2008-9-15 $
 */
package com.hgy.commonsale.webui.action;

import org.geln.web.Constants;
import org.geln.web.webwork.action.Protected;
import com.hgy.commonsale.service.IUserManager;
import com.hgy.commonsale.user.domain.User;
import com.opensymphony.xwork.ActionContext;

/**
 * @Author:Geln Yang
 * @Created:2008-9-15
 */
public class ProtectedAction extends BasalAction implements Protected {
	protected IUserManager userManager;

	public final void setUserManager(IUserManager userManager) {
		this.userManager = userManager;
	}

	public final User getCurrentUser() {
		return userManager.getUserById((String) ActionContext.getContext().getSession().get(Constants.ACCOUNT));
	}

	@SuppressWarnings("unchecked")
	public final void setCurrentUser(User user) {
		ActionContext.getContext().getSession().put(Constants.ACCOUNT, user.getAccount());
	}

}
